package com.guandi.geekbrowser.primary.repository;

import com.guandi.geekbrowser.primary.entity.Tab;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

@Repository
public interface TabRepository extends JpaRepository<Tab,Long> {

    List<Tab> findByName(String name);

    Optional<Tab> findById(Long id);

    List<Tab> findByUserId(String id);

    List<Tab> findByUserIdAndDel(String id,Boolean del);

    List<Tab> findByUserIdAndDelAndId(String id,Boolean del,Long did);

    List<Tab> findByUserIdAndDelAndCountry(String id,Boolean del,String country);

    List<Tab> findByUserIdAndCountry(String id,String country);

    List<Tab> findByUserIdAndCountryAndType(String id,String country,Integer type);

    @Transactional
    void deleteByUserIdAndName(String id, String name);

    @Transactional
    void deleteByUserIdAndNameAndCountry(String id, String name,String country);

    Tab findByUserIdAndName(String id,String name);

    Tab findByUserIdAndNameAndCountry(String id,String name,String country);



}
